home *** CD-ROM | disk | FTP | other *** search
/ Champak 54 / Vol 54.iso / games / thelosti.swf / scripts / frame_7 / DoAction.as
Encoding:
Text File  |  2007-10-01  |  48.0 KB  |  1,622 lines

  1. function initMenu()
  2. {
  3.    menu_mc.tali_mc.gotoAndStop(1);
  4.    menu_mc.jalan_mc.gotoAndStop(2);
  5.    menu_mc.mark_mc.gotoAndStop(1);
  6.    menu_mc.jason_mc.gotoAndStop(2);
  7.    menu_mc.nama_mc.gotoAndStop(1);
  8.    menu_mc.jason_mc.enabled = true;
  9.    menu_mc.mark_mc.enabled = true;
  10.    menu_mc.tali_mc.enabled = true;
  11.    menu_mc.jalan_mc.enabled = true;
  12.    menu_mc.mark_mc.onRelease = char1.onRelease = function()
  13.    {
  14.       if(!xjatuh)
  15.       {
  16.          sChar = 1;
  17.          dChar = 0;
  18.          menu_mc.mark_mc.gotoAndStop(1);
  19.          menu_mc.jason_mc.gotoAndStop(2);
  20.          menu_mc.nama_mc.gotoAndStop(1);
  21.       }
  22.    };
  23.    menu_mc.jason_mc.onRelease = char0.onRelease = function()
  24.    {
  25.       if(!xjatuh)
  26.       {
  27.          sChar = 0;
  28.          dChar = 1;
  29.          menu_mc.mark_mc.gotoAndStop(2);
  30.          menu_mc.jason_mc.gotoAndStop(1);
  31.          menu_mc.nama_mc.gotoAndStop(2);
  32.       }
  33.    };
  34.    menu_mc.jalan_mc.onRelease = function()
  35.    {
  36.       abilChar = "jalan";
  37.       menu_mc.tali_mc.gotoAndStop(2);
  38.       menu_mc.jalan_mc.gotoAndStop(1);
  39.    };
  40.    menu_mc.tali_mc.onRelease = function()
  41.    {
  42.       abilChar = "tali";
  43.       menu_mc.tali_mc.gotoAndStop(1);
  44.       menu_mc.jalan_mc.gotoAndStop(2);
  45.    };
  46.    menu_mc.reset_btn.enabled = true;
  47.    menu_mc.back_btn.enabled = true;
  48.    menu_mc.reset_btn.onRelease = function()
  49.    {
  50.       cekLose();
  51.    };
  52.    menu_mc.back_btn.onRelease = function()
  53.    {
  54.       clearSemua();
  55.       _root.gotoAndStop(2);
  56.    };
  57. }
  58. function clearSemua()
  59. {
  60.    delete _root.onEnterFrame;
  61.    clearInterval(idJatuh);
  62.    clearInterval(idWaktu);
  63.    i = 0;
  64.    while(i <= panjang)
  65.    {
  66.       j = 0;
  67.       while(j <= lebar)
  68.       {
  69.          ubahDalam("i","j","dalam");
  70.          namaBaru = "kotak" + dalam;
  71.          removeMovieClip(_root[namaBaru]);
  72.          removeMovieClip("back_mc");
  73.          removeMovieClip("menu_mc");
  74.          removeMovieClip("char0");
  75.          removeMovieClip("char1");
  76.          removeMovieClip("msgBox_mc");
  77.          j++;
  78.       }
  79.       i++;
  80.    }
  81. }
  82. function initAwal()
  83. {
  84.    mapKe = 1;
  85.    back_mc.gotoAndStop(mapKe);
  86.    waktu = 0;
  87. }
  88. function waktuMaju()
  89. {
  90.    waktu++;
  91. }
  92. function init()
  93. {
  94.    panjang = 19;
  95.    lebar = 14;
  96.    speedChar0 = 3;
  97.    speedChar1 = 5;
  98.    jumlahKeluar = 0;
  99.    xtaliNaik = false;
  100.    xtaliTurun = false;
  101.    xjatuh = false;
  102.    xbisa = false;
  103.    batuJatuh = undefined;
  104.    sudahJatuh = false;
  105.    sedangBuatTali = false;
  106.    sedangAngkat = false;
  107.    xambilTali = false;
  108.    xdiem = false;
  109.    switchBuka = false;
  110.    sedangNahan = false;
  111.    posisiXChar = new Array();
  112.    posisiYChar = new Array();
  113.    posChar = new Array();
  114.    jatuhChar = new Array();
  115.    xposSwitchJ = new Array(10,10,3);
  116.    xposSwitchI = new Array(10,8,11);
  117.    xposBukaJ = new Array(1,10,3);
  118.    xposBukaI = new Array(3,14,19);
  119.    xswitchBuka = new Array(false,false,false);
  120.    sudahAtas = new Array();
  121.    sudahBawah = new Array();
  122.    gerakBawahAwal = new Array();
  123.    gerakAtasAwal = new Array();
  124.    awalTurun = new Array(false,false);
  125.    dalam1 = 1;
  126.    abilChar = "tali";
  127.    if(mapKe == 1)
  128.    {
  129.       tanah = 3;
  130.       tali = 2;
  131.       back_mc.kotak2._visible = false;
  132.       back_mc.kotak1._visible = false;
  133.    }
  134.    else if(mapKe == 2)
  135.    {
  136.       tanah = 4;
  137.       tali = 2;
  138.       back_mc.kotak2._visible = false;
  139.       back_mc.kotak1._visible = true;
  140.    }
  141.    else if(mapKe == 3)
  142.    {
  143.       tanah = 3;
  144.       tali = 2;
  145.       back_mc.kotak2._visible = true;
  146.       back_mc.kotak1._visible = false;
  147.    }
  148.    sChar = 1;
  149.    dChar = 0;
  150.    jumlahChar = 2;
  151.    mapping1 = [[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[10,7,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[1,1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0,7,6,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,15,15],[0,0,0,0,0,0,0,0,0,9,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,9,0,0,0,0,0,16,0,0,0,0],[0,0,0,0,0,1,1,1,1,1,8,0,0,1,1,1,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,16,0,0,0,11,0,0,0,0,0,0],[2,3,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0],[1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]];
  152.    mapping2 = [[0,0,7,0,19,19,0,0,0,0,0,0,0,0,0,0,0,0,13,0],[0,0,7,10,19,19,0,0,7,7,7,7,0,0,0,0,0,0,0,0],[1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,16,6,0,11,0,0,0,0,0,0,0,10],[0,0,0,0,0,0,0,0,7,7,7,7,0,0,0,1,1,1,0,1],[1,1,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9,9,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9,9,0,0],[0,0,0,0,1,1,1,0,1,8,1,1,1,1,1,1,1,1,1,1],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[2,3,0,0,0,0,0,0,11,0,11,0,0,0,10,0,0,0,0,12],[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]];
  153.    mapping3 = [[0,0,0,0,0,0,13,1,1,1,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[2,3,0,0,0,0,0,10,16,12,0,0,0,0,0,9,0,0,0,0],[1,1,1,0,0,1,0,1,1,1,1,0,0,0,1,1,18,1,1,1],[0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,1,0,0,0],[0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,1,1,1,1,0,0,0,1,1,0,0,1,0,0,0,19,19],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19],[0,0,0,0,0,0,0,0,0,7,9,9,0,0,0,0,0,1,1,1],[0,0,0,0,0,0,0,0,0,9,7,9,0,0,0,0,0,0,0,0],[0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,11,6,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]];
  154. }
  155. function buatKotak()
  156. {
  157.    batuJatuh2 = false;
  158.    mapping = this["mapping" + mapKe];
  159.    adaJem = new Array();
  160.    i = 0;
  161.    while(i <= panjang)
  162.    {
  163.       adaJem[i] = new Array();
  164.       j = 0;
  165.       while(j <= lebar)
  166.       {
  167.          adaJem[j][i] = false;
  168.          ubahDalam("i","j","dalam");
  169.          namaBaru = "kotak" + dalam;
  170.          this.attachMovie("kotak_mc",namaBaru,dalam1);
  171.          iniJalan = false;
  172.          if(mapping[j][i] == 0)
  173.          {
  174.             this[namaBaru].gotoAndStop(1);
  175.          }
  176.          else if(mapping[j][i] == 1)
  177.          {
  178.             this[namaBaru].gotoAndStop(2);
  179.          }
  180.          else if(mapping[j][i] == 2)
  181.          {
  182.             this[namaBaru].gotoAndStop(1);
  183.             this.attachMovie("char0","char0",1000);
  184.             posisiXChar[0] = j;
  185.             posisiYChar[0] = i;
  186.             char0._x = i * 40;
  187.             char0._y = j * 40;
  188.             mapping[j][i] = 0;
  189.          }
  190.          else if(mapping[j][i] == 3)
  191.          {
  192.             this[namaBaru].gotoAndStop(1);
  193.             this.attachMovie("char1","char1",1001);
  194.             posisiXChar[1] = j;
  195.             posisiYChar[1] = i;
  196.             char1._x = i * 40;
  197.             char1._y = j * 40;
  198.             mapping[j][i] = 0;
  199.          }
  200.          else if(mapping[j][i] == 4)
  201.          {
  202.             this[namaBaru].gotoAndStop(4);
  203.          }
  204.          else if(mapping[j][i] == 6)
  205.          {
  206.             this[namaBaru].gotoAndStop(6);
  207.          }
  208.          else if(mapping[j][i] == 7)
  209.          {
  210.             this[namaBaru].gotoAndStop(7);
  211.          }
  212.          else if(mapping[j][i] == 8)
  213.          {
  214.             this[namaBaru].gotoAndStop(8);
  215.          }
  216.          else if(mapping[j][i] == 9)
  217.          {
  218.             this[namaBaru].gotoAndStop(9);
  219.          }
  220.          else if(mapping[j][i] == 10)
  221.          {
  222.             this[namaBaru].gotoAndStop(10);
  223.          }
  224.          else if(mapping[j][i] == 11)
  225.          {
  226.             mapping[j - 1][i] = 7;
  227.             mapping[j][i] = 7;
  228.             this[namaBaru].gotoAndStop(11);
  229.             posSwitchJ = j;
  230.             posSwitchI = i;
  231.          }
  232.          else if(mapping[j][i] == 12)
  233.          {
  234.             this[namaBaru].gotoAndStop(12);
  235.          }
  236.          else if(mapping[j][i] == 13)
  237.          {
  238.             mapping[j][i] = 7;
  239.             this[namaBaru].gotoAndStop(13);
  240.             this[namaBaru]._visible = false;
  241.          }
  242.          else if(mapping[j][i] == 14)
  243.          {
  244.             batuJatuh2 = true;
  245.             mapping[j][i] = 7;
  246.             this[namaBaru].gotoAndStop(14);
  247.             batu2 = namaBaru;
  248.             xbatu2 = namaBaru;
  249.          }
  250.          else if(mapping[j][i] == 15)
  251.          {
  252.             mapping[j][i] = 0;
  253.             this[namaBaru].gotoAndStop(15);
  254.          }
  255.          else if(mapping[j][i] == 16)
  256.          {
  257.             mapping[j][i] = 7;
  258.             this[namaBaru].gotoAndStop(16);
  259.          }
  260.          else if(mapping[j][i] == 17)
  261.          {
  262.             mapping[j - 1][i] = 7;
  263.             mapping[j][i] = 7;
  264.             this[namaBaru].gotoAndStop(17);
  265.          }
  266.          else if(mapping[j][i] == 18)
  267.          {
  268.             mapping[j][i] = 0;
  269.             this[namaBaru].gotoAndStop(18);
  270.          }
  271.          else if(mapping[j][i] == 19)
  272.          {
  273.             mapping[j][i] = 7;
  274.          }
  275.          this[namaBaru]._x = i * 40;
  276.          this[namaBaru]._y = j * 40;
  277.          dalam1++;
  278.          j++;
  279.       }
  280.       i++;
  281.    }
  282. }
  283. function jatuh()
  284. {
  285.    if(xjatuh)
  286.    {
  287.       if(posisiXChar[sChar] <= lebar)
  288.       {
  289.          posisiXChar[sChar]++;
  290.          _root["char" + sChar]._y = posisiXChar[sChar] * 40;
  291.          if(mapping[posisiXChar[sChar] + 1][posisiYChar[sChar]] == 1 || mapping[posisiXChar[sChar] + 1][posisiYChar[sChar]] == 4 || mapping[posisiXChar[sChar] + 1][posisiYChar[sChar]] == 9)
  292.          {
  293.             xjatuh = false;
  294.          }
  295.       }
  296.       else
  297.       {
  298.          xjatuh = false;
  299.          cekLose();
  300.       }
  301.    }
  302.    if(sudahJatuh == true)
  303.    {
  304.       if(batuJatuh)
  305.       {
  306.          _root[batu].gotoAndStop(7);
  307.          myStr = new String(_root[batu]);
  308.          indiI = int(myStr.substr(myStr.length - 4,2));
  309.          indiJ = int(myStr.substr(myStr.length - 2,2));
  310.          indiJ++;
  311.          xindiJ = indiJ - 1;
  312.          ubahDalam("indiI","indiJ","dalam2");
  313.          namaBaru2 = "kotak" + dalam2;
  314.          if(posisiXChar[0] == indiJ + 1 && posisiYChar[0] == indiI)
  315.          {
  316.             char0.anim_char.gotoAndStop(9);
  317.             sedangNahan = true;
  318.             batuJatuh = false;
  319.          }
  320.          else if(posisiXChar[1] == indiJ && posisiYChar[1] == indiI)
  321.          {
  322.             cekLose();
  323.          }
  324.          else if(_root[namaBaru2]._currentframe == 2 || _root[namaBaru2]._currentframe == 5 || _root[namaBaru2]._currentframe == 9 || _root[namaBaru2]._currentframe == 7)
  325.          {
  326.             sudahJatuh = false;
  327.             batuJatuh = false;
  328.             mapping[xindiJ - 1][indiI] = 0;
  329.             mapping[indiJ - 1][indiI] = 7;
  330.          }
  331.          else
  332.          {
  333.             batuJatuh = true;
  334.             _root[namaBaru2].gotoAndStop(13);
  335.             _root[batu].gotoAndStop(1);
  336.             mapping[xindiJ][indiI] = 1;
  337.             mapping[indiJ][indiI] = 7;
  338.             batu = namaBaru2;
  339.          }
  340.       }
  341.    }
  342.    if(batuJatuh2)
  343.    {
  344.       _root[batu2].gotoAndStop(14);
  345.       myStr = new String(_root[batu2]);
  346.       indiI = int(myStr.substr(myStr.length - 4,2));
  347.       indiJ = int(myStr.substr(myStr.length - 2,2));
  348.       indiJ++;
  349.       xindiJ = indiJ - 1;
  350.       ubahDalam("indiI","indiJ","dalam2");
  351.       namaBaru2 = "kotak" + dalam2;
  352.       if(_root[namaBaru2]._currentframe == 2)
  353.       {
  354.          _root[batu2].gotoAndStop(1);
  355.          _root[xbatu2].gotoAndStop(14);
  356.          batu2 = xbatu2;
  357.          batuJatuh2 = true;
  358.          mapping[xindiJ][indiI] = 1;
  359.          mapping[indiJ][indiI] = 7;
  360.       }
  361.       else if(posisiXChar[0] == indiJ + 1 && posisiYChar[0] == indiI)
  362.       {
  363.          batuJatuh2 = false;
  364.       }
  365.       else
  366.       {
  367.          batuJatuh2 = true;
  368.          _root[namaBaru2].gotoAndStop(14);
  369.          _root[batu2].gotoAndStop(1);
  370.          mapping[xindiJ][indiI] = 1;
  371.          mapping[indiJ][indiI] = 7;
  372.          batu2 = namaBaru2;
  373.       }
  374.    }
  375. }
  376. function cekLose()
  377. {
  378.    init();
  379.    buatKotak();
  380.    buatChar();
  381.    initMenu();
  382. }
  383. function cekWin()
  384. {
  385.    if(mapping[posisiXChar[sChar]][posisiYChar[sChar]] == 6)
  386.    {
  387.       jumlahKeluar++;
  388.       _root["char" + sChar]._visible = false;
  389.       xjatuh = false;
  390.       if(sChar == 1)
  391.       {
  392.          sChar = 0;
  393.          dChar = 1;
  394.          menu_mc.mark_mc.enabled = false;
  395.          menu_mc.tali_mc.enabled = false;
  396.          menu_mc.jalan_mc.enabled = false;
  397.          menu_mc.tali_mc.gotoAndStop(2);
  398.          menu_mc.jalan_mc.gotoAndStop(2);
  399.          menu_mc.jalan_mc.enabled = false;
  400.          menu_mc.nama_mc.gotoAndStop(2);
  401.          menu_mc.jason_mc.gotoAndStop(1);
  402.          menu_mc.mark_mc.gotoAndStop(2);
  403.       }
  404.       else if(sChar == 0)
  405.       {
  406.          sChar = 1;
  407.          dChar = 0;
  408.          menu_mc.nama_mc.gotoAndStop(1);
  409.          menu_mc.jason_mc.gotoAndStop(2);
  410.          menu_mc.mark_mc.gotoAndStop(1);
  411.          menu_mc.jason_mc.enabled = false;
  412.       }
  413.    }
  414.    if(jumlahKeluar == 2)
  415.    {
  416.       mapKe++;
  417.       if(mapKe <= 3)
  418.       {
  419.          back_mc.gotoAndStop(mapKe);
  420.          init();
  421.          buatKotak();
  422.          buatChar();
  423.          initMenu();
  424.       }
  425.       else
  426.       {
  427.          mulaiMain = false;
  428.          clearInterval(idWaktu);
  429.          menu_mc.reset_btn.enabled = false;
  430.          menu_mc.back_btn.enabled = true;
  431.          _root.attachMovie("msgBox_mc","msgBox_mc",100000);
  432.          msgBox_mc._x = Stage.width / 2;
  433.          msgBox_mc._y = Stage.height / 2 - 100;
  434.          msgBox_mc.yes_btn.onRelease = function()
  435.          {
  436.             msgBox_mc.gotoAndStop(2);
  437.          };
  438.          msgBox_mc.no_btn.onRelease = function()
  439.          {
  440.             clearSemua();
  441.             _root.gotoAndStop(2);
  442.          };
  443.       }
  444.    }
  445. }
  446. function topTen()
  447. {
  448.    skorOrang = String(waktu);
  449.    rand1 = Math.random() * 1000000;
  450.    myData = new LoadVars();
  451.    myData.sendAndLoad("flash_scores.php?" + rand1 + "&newname=" + namaOrang + "&newscore=" + skorOrang,"POST");
  452.    myData.onLoad = function(success)
  453.    {
  454.       if(success)
  455.       {
  456.          delete msgBox_mc.onEnterFrame;
  457.          clearSemua();
  458.          gotoAndStop("high");
  459.       }
  460.       else
  461.       {
  462.          delete msgBox_mc.onEnterFrame;
  463.          msgBox_mc.gotoAndStop(3);
  464.       }
  465.    };
  466. }
  467. function topTen2()
  468. {
  469.    clearSemua();
  470.    gotoAndStop("menu");
  471. }
  472. function klikChar1()
  473. {
  474.    if(!xjatuh)
  475.    {
  476.       sChar = 0;
  477.       dChar = 1;
  478.    }
  479. }
  480. function klikChar2()
  481. {
  482.    if(!xjatuh)
  483.    {
  484.       sChar = 1;
  485.       dChar = 0;
  486.    }
  487. }
  488. function cekChar(indi)
  489. {
  490.    if(mapping[posisiXChar[sChar] + 1][posisiYChar[sChar]] == 0)
  491.    {
  492.       xjatuh = true;
  493.    }
  494.    else if(mapping[posisiXChar[sChar] + 1][posisiYChar[sChar]] == 8)
  495.    {
  496.       j = posisiXChar[sChar] + 1;
  497.       i = posisiYChar[sChar];
  498.       cekDalam(1);
  499.       mapping[j][i] = 0;
  500.       xjatuh = true;
  501.    }
  502.    else if(mapping[posisiXChar[sChar]][posisiYChar[sChar]] == 10)
  503.    {
  504.       if(mapKe == 2)
  505.       {
  506.          i = 0;
  507.          while(i <= 2)
  508.          {
  509.             if(posisiXChar[sChar] == xposBukaJ[i] && posisiYChar[sChar] == xposBukaI[i])
  510.             {
  511.                posisiKe = i;
  512.                i = 2;
  513.             }
  514.             i++;
  515.          }
  516.       }
  517.       cekBuka("pintu");
  518.    }
  519.    else if(mapping[posisiXChar[sChar]][posisiYChar[sChar]] == 12)
  520.    {
  521.       cekBuka("batu");
  522.    }
  523. }
  524. function cekBuka(opsi)
  525. {
  526.    i = 0;
  527.    while(i <= panjang)
  528.    {
  529.       j = 0;
  530.       while(j <= lebar)
  531.       {
  532.          ubahDalam("i","j","dalam");
  533.          namaBaru = "kotak" + dalam;
  534.          if(opsi == "pintu")
  535.          {
  536.             if(mapKe == 2)
  537.             {
  538.                if(j == xposSwitchJ[posisiKe] && i == xposSwitchI[posisiKe])
  539.                {
  540.                   if(xswitchBuka[posisiKe] == false)
  541.                   {
  542.                      xswitchBuka[posisiKe] = true;
  543.                      _root[namaBaru].gotoAndStop(1);
  544.                      mapping[j - 1][i] = 0;
  545.                      mapping[j][i] = 0;
  546.                   }
  547.                   else
  548.                   {
  549.                      xswitchBuka[posisiKe] = false;
  550.                      _root[namaBaru].gotoAndStop(11);
  551.                      mapping[j - 1][i] = 7;
  552.                      mapping[j][i] = 7;
  553.                   }
  554.                   i = panjang;
  555.                   j = lebar;
  556.                }
  557.             }
  558.             else if(j == posSwitchJ && i == posSwitchI)
  559.             {
  560.                if(switchBuka == false)
  561.                {
  562.                   switchBuka = true;
  563.                   _root[namaBaru].gotoAndStop(1);
  564.                   mapping[j - 1][i] = 0;
  565.                   mapping[j][i] = 0;
  566.                }
  567.                else
  568.                {
  569.                   switchBuka = false;
  570.                   _root[namaBaru].gotoAndStop(11);
  571.                   mapping[j - 1][i] = 7;
  572.                   mapping[j][i] = 7;
  573.                }
  574.                i = panjang;
  575.                j = lebar;
  576.             }
  577.          }
  578.          else if(opsi == "batu")
  579.          {
  580.             if(_root[namaBaru]._currentframe == 13)
  581.             {
  582.                batu = namaBaru;
  583.                batuJatuh = true;
  584.                i = panjang;
  585.                j = lebar;
  586.                sudahJatuh = true;
  587.             }
  588.          }
  589.          j++;
  590.       }
  591.       i++;
  592.    }
  593. }
  594. function gerakKanan()
  595. {
  596.    if(mapping[posisiXChar[sChar] + 1][posisiYChar[sChar] + 1] != 0 || mapping[posisiXChar[sChar]][posisiYChar[sChar] + 1] == 6)
  597.    {
  598.       if(mapping[posisiXChar[sChar] - 1][posisiYChar[sChar] + 1] != 7 && mapping[posisiXChar[sChar] - 1][posisiYChar[sChar] + 1] != 9)
  599.       {
  600.          if(posisiYChar[sChar] + 1 <= panjang && (mapping[posisiXChar[sChar]][posisiYChar[sChar] + 1] != 7 && mapping[posisiXChar[sChar]][posisiYChar[sChar] + 1] != 9))
  601.          {
  602.             _root["char" + sChar].anim_char.gotoAndStop(2);
  603.             jalanKanan = true;
  604.             xdiem = true;
  605.             gerakAtasAwal[sChar] = true;
  606.             gerakBawahAwal[sChar] = true;
  607.          }
  608.       }
  609.    }
  610. }
  611. function gerakKiri()
  612. {
  613.    if(mapping[posisiXChar[sChar] + 1][posisiYChar[sChar] - 1] != 0 || mapping[posisiXChar[sChar]][posisiYChar[sChar] - 1] == 6)
  614.    {
  615.       if(mapping[posisiXChar[sChar] - 1][posisiYChar[sChar] - 1] != 7 && mapping[posisiXChar[sChar] - 1][posisiYChar[sChar] - 1] != 9)
  616.       {
  617.          if(posisiYChar[sChar] - 1 >= 0 && (mapping[posisiXChar[sChar]][posisiYChar[sChar] - 1] != 7 && mapping[posisiXChar[sChar]][posisiYChar[sChar] - 1] != 9))
  618.          {
  619.             _root["char" + sChar].anim_char.gotoAndStop(2);
  620.             jalanKiri = true;
  621.             xdiem = true;
  622.             gerakAtasAwal[sChar] = true;
  623.             gerakBawahAwal[sChar] = true;
  624.          }
  625.       }
  626.    }
  627. }
  628. function gerakAtas()
  629. {
  630.    if(sedangAngkat == false && sChar == 0 || sChar == 1)
  631.    {
  632.       if(mapping[posisiXChar[sChar] - 1][posisiYChar[sChar]] != 7 && mapping[posisiXChar[sChar] - 1][posisiYChar[sChar]] != 9)
  633.       {
  634.          j = posisiXChar[sChar];
  635.          i = posisiYChar[sChar];
  636.          cekDalam();
  637.          if(_root[namaBaru]._currentframe == 4 || _root[namaBaru]._currentframe == 5)
  638.          {
  639.             if(mapping[j - 2][i] == 0 || mapping[j - 2][i] == 10 || mapping[j - 2][i] == 12)
  640.             {
  641.                sudahAtas[sChar] = true;
  642.             }
  643.             else
  644.             {
  645.                sudahAtas[sChar] = false;
  646.             }
  647.             gerakBawahAwal[sChar] = false;
  648.             if(gerakAtasAwal[sChar])
  649.             {
  650.                _root["char" + sChar].anim_char.gotoAndStop(4);
  651.                _root["char" + sChar].anim_char.naik.gotoAndStop(1);
  652.                gerakAtasAwal[sChar] = false;
  653.                jalanAtas = true;
  654.             }
  655.             else
  656.             {
  657.                _root["char" + sChar].anim_char.gotoAndStop(4);
  658.                _root["char" + sChar].anim_char.naik.gotoAndPlay(1);
  659.                jalanAtas = true;
  660.                xdiem = true;
  661.             }
  662.          }
  663.       }
  664.    }
  665. }
  666. function gerakBawah()
  667. {
  668.    if(sedangAngkat == false && sChar == 0 || sChar == 1)
  669.    {
  670.       if(mapping[posisiXChar[sChar] + 1][posisiYChar[sChar]] != 7)
  671.       {
  672.          j = posisiXChar[sChar] + 1;
  673.          i = posisiYChar[sChar];
  674.          cekDalam();
  675.          if(_root[namaBaru]._currentframe == 4 || _root[namaBaru]._currentframe == 5)
  676.          {
  677.             if(sChar == 0 && sedangNahan == false || sChar == 1)
  678.             {
  679.                if(mapping[j - 1][i] == 0 || mapping[j - 1][i] == 10 || mapping[j - 1][i] == 12)
  680.                {
  681.                   sudahBawah[sChar] = true;
  682.                }
  683.                else
  684.                {
  685.                   sudahBawah[sChar] = false;
  686.                }
  687.                if(gerakBawahAwal[sChar])
  688.                {
  689.                   _root["char" + sChar].anim_char.gotoAndStop(5);
  690.                   _root["char" + sChar].anim_char.bawah.gotoAndPlay(1);
  691.                   gerakBawahAwal[sChar] = false;
  692.                   jalanBawah = true;
  693.                   xdiem = true;
  694.                   awalTurun[sChar] = true;
  695.                }
  696.                else
  697.                {
  698.                   j = posisiXChar[sChar] + 2;
  699.                   i = posisiYChar[sChar];
  700.                   cekDalam();
  701.                   if(_root[namaBaru]._currentframe != 4)
  702.                   {
  703.                      posisiXChar[sChar]++;
  704.                      _root["char" + sChar].anim_char.gotoAndStop(1);
  705.                      _root["char" + sChar]._y = posisiXChar[sChar] * 40;
  706.                      gerakBawahAwal[sChar] = true;
  707.                      awalTurun[sChar] = false;
  708.                   }
  709.                   else
  710.                   {
  711.                      awalTurun[sChar] = false;
  712.                      _root["char" + sChar].anim_char.gotoAndStop(5);
  713.                      _root["char" + sChar].anim_char.bawah.gotoAndPlay(10);
  714.                      jalanBawah = true;
  715.                      xdiem = true;
  716.                   }
  717.                }
  718.             }
  719.          }
  720.          cekWin();
  721.       }
  722.    }
  723. }
  724. function buatJalan()
  725. {
  726.    if(tanah >= 1)
  727.    {
  728.       if(_root["char" + sChar]._currentframe == 1)
  729.       {
  730.          j = posisiXChar[sChar] + 1;
  731.          i = posisiYChar[sChar] + 1;
  732.       }
  733.       else if(_root["char" + sChar]._currentframe == 2)
  734.       {
  735.          j = posisiXChar[sChar] + 1;
  736.          i = posisiYChar[sChar] - 1;
  737.       }
  738.       if(mapping[posisiXChar[sChar]][posisiYChar[sChar]] == 0 && (mapping[posisiXChar[sChar] + 1][posisiYChar[sChar]] == 4 || mapping[posisiXChar[sChar] + 1][posisiYChar[sChar]] == 1))
  739.       {
  740.          if(mapping[j][i] != 1)
  741.          {
  742.             _root["char" + sChar].anim_char.gotoAndStop(6);
  743.             tanah--;
  744.          }
  745.          iniJalan = true;
  746.          cekDalam(2);
  747.          adaJem[j][i] = true;
  748.          mapping[j][i] = 1;
  749.       }
  750.    }
  751. }
  752. function buatTali()
  753. {
  754.    if(sedangBuatTali)
  755.    {
  756.       if(tali >= 1)
  757.       {
  758.          if(_root["char" + sChar]._currentframe == 1 || _root["char" + sChar]._currentframe == 2)
  759.          {
  760.             j = posisiXChar[sChar];
  761.             i = posisiYChar[sChar];
  762.          }
  763.          tali--;
  764.          tanda = 5;
  765.          taliNaik = true;
  766.          idTali = setInterval(xtali,250);
  767.       }
  768.    }
  769. }
  770. function buatTali2()
  771. {
  772.    if(sedangBuatTali)
  773.    {
  774.       if(tali >= 1)
  775.       {
  776.          if(_root["char" + sChar]._currentframe == 1 || _root["char" + sChar]._currentframe == 2)
  777.          {
  778.             j = posisiXChar[sChar] + 1;
  779.             i = posisiYChar[sChar];
  780.          }
  781.          tali--;
  782.          tanda = 5;
  783.          iniJalan = true;
  784.          taliNaik = true;
  785.          idTali2 = setInterval(xtali2,250);
  786.       }
  787.    }
  788. }
  789. function cekTeman(posisi)
  790. {
  791.    if(posisi == "kanan")
  792.    {
  793.       xj = posisiXChar[sChar];
  794.       xi = posisiYChar[sChar] + 1;
  795.    }
  796.    else if(posisi == "kiri")
  797.    {
  798.       xj = posisiXChar[sChar];
  799.       xi = posisiYChar[sChar] - 1;
  800.    }
  801.    else if(posisi == "atas")
  802.    {
  803.       xj = posisiXChar[sChar] - 1;
  804.       xi = posisiYChar[sChar];
  805.    }
  806.    else if(posisi == "bawah")
  807.    {
  808.       xj = posisiXChar[sChar] + 1;
  809.       xi = posisiYChar[sChar];
  810.    }
  811.    if(xj == posisiXChar[dChar] && xi == posisiYChar[dChar])
  812.    {
  813.       xbisa = false;
  814.    }
  815.    else if(mapping[xj + 1][xi] == 0)
  816.    {
  817.       xbisa = false;
  818.    }
  819.    else if(!(xj - 1 == posisiXChar[dChar] && xi == posisiYChar[dChar]))
  820.    {
  821.       xbisa = true;
  822.    }
  823. }
  824. function ambilTali()
  825. {
  826.    if(xambilTali)
  827.    {
  828.       xdiem = true;
  829.       j = posisiAmbilX2;
  830.       i = posisiAmbilY;
  831.       if(adaJem[j][i])
  832.       {
  833.          iniJalan = true;
  834.       }
  835.       else
  836.       {
  837.          iniJalan = false;
  838.       }
  839.       cekDalam(1);
  840.       mapping[j][i] = 0;
  841.       posisiAmbilX2--;
  842.       if(posisiAmbilX2 == posisiAmbilX)
  843.       {
  844.          tali++;
  845.          j = posisiAmbilX2;
  846.          i = posisiAmbilY;
  847.          if(adaJem[j][i])
  848.          {
  849.             iniJalan = true;
  850.          }
  851.          else
  852.          {
  853.             iniJalan = false;
  854.          }
  855.          cekDalam(2);
  856.          mapping[posisiAmbilX2][posisiAmbilY] = 1;
  857.          xambilTali = false;
  858.          xdiem = false;
  859.          clearInterval(idAmbil);
  860.       }
  861.    }
  862. }
  863. function ambilTali2()
  864. {
  865.    if(xambilTali)
  866.    {
  867.       xdiem = true;
  868.       j = posisiAmbilX2;
  869.       i = posisiAmbilY;
  870.       if(adaJem[j][i])
  871.       {
  872.          iniJalan = true;
  873.       }
  874.       else
  875.       {
  876.          iniJalan = false;
  877.       }
  878.       cekDalam(1);
  879.       mapping[j][i] = 0;
  880.       posisiAmbilX2++;
  881.       if(posisiAmbilX2 == posisiAmbilX)
  882.       {
  883.          tali++;
  884.          j = posisiAmbilX2;
  885.          i = posisiAmbilY;
  886.          if(adaJem[j][i])
  887.          {
  888.             iniJalan = true;
  889.          }
  890.          else
  891.          {
  892.             iniJalan = false;
  893.          }
  894.          cekDalam(1);
  895.          mapping[posisiAmbilX2][posisiAmbilY] = 0;
  896.          xambilTali = false;
  897.          xdiem = false;
  898.          clearInterval(idAmbil2);
  899.       }
  900.    }
  901. }
  902. function xtali()
  903. {
  904.    if(sedangBuatTali)
  905.    {
  906.       if(taliNaik)
  907.       {
  908.          cekDalam(4);
  909.          mapping[j][i] = 4;
  910.          j--;
  911.          tanda--;
  912.          if(mapping[j][i] == 1)
  913.          {
  914.             clearInterval(idTali);
  915.             if(adaJem[j][i])
  916.             {
  917.                iniJalan = true;
  918.             }
  919.             else
  920.             {
  921.                iniJalan = false;
  922.             }
  923.             cekDalam(5);
  924.             mapping[j][i] = 4;
  925.             sedangBuatTali = false;
  926.             xdiem = false;
  927.          }
  928.          else if(tanda <= 0 || mapping[j][i] == undefined || mapping[j][i] >= 6)
  929.          {
  930.             taliNaik = false;
  931.          }
  932.       }
  933.       else
  934.       {
  935.          if(mapping[j][i] < 6)
  936.          {
  937.             cekDalam(1);
  938.             mapping[j][i] = 0;
  939.          }
  940.          j++;
  941.          ubahDalam("i","j","dalam");
  942.          namaBaru = "kotak" + dalam;
  943.          if(mapping[j][i] == 1 || _root[namaBaru]._currentframe == 5)
  944.          {
  945.             clearInterval(idTali);
  946.             sedangBuatTali = false;
  947.             xdiem = false;
  948.             tali++;
  949.          }
  950.       }
  951.    }
  952. }
  953. function xtali2()
  954. {
  955.    if(sedangBuatTali)
  956.    {
  957.       if(taliNaik)
  958.       {
  959.          if(tanda == 5)
  960.          {
  961.             if(adaJem[j][i])
  962.             {
  963.                iniJalan = true;
  964.             }
  965.             else
  966.             {
  967.                iniJalan = false;
  968.             }
  969.             cekDalam(5);
  970.             mapping[j][i] = 4;
  971.          }
  972.          else
  973.          {
  974.             if(adaJem[j][i])
  975.             {
  976.                iniJalan = true;
  977.             }
  978.             else
  979.             {
  980.                iniJalan = false;
  981.             }
  982.             cekDalam(4);
  983.             mapping[j][i] = 4;
  984.          }
  985.          j++;
  986.          tanda--;
  987.          if(mapping[j][i] == 1 || mapping[j][i] == 4)
  988.          {
  989.             clearInterval(idTali2);
  990.             sedangBuatTali = false;
  991.             xdiem = false;
  992.          }
  993.          else if(tanda <= 0 || mapping[j][i] == undefined || mapping[j][i] >= 6)
  994.          {
  995.             taliNaik = false;
  996.          }
  997.       }
  998.       else
  999.       {
  1000.          if(mapping[j][i] < 6)
  1001.          {
  1002.             cekDalam(1);
  1003.             mapping[j][i] = 0;
  1004.          }
  1005.          j--;
  1006.          ubahDalam("i","j","dalam");
  1007.          namaBaru = "kotak" + dalam;
  1008.          if(mapping[j][i] == 1 || _root[namaBaru]._currentframe == 5)
  1009.          {
  1010.             if(adaJem[j][i])
  1011.             {
  1012.                iniJalan = true;
  1013.             }
  1014.             else
  1015.             {
  1016.                iniJalan = false;
  1017.             }
  1018.             cekDalam(2);
  1019.             mapping[j][i] = 1;
  1020.             clearInterval(idTali2);
  1021.             sedangBuatTali = false;
  1022.             xdiem = false;
  1023.             tali++;
  1024.          }
  1025.       }
  1026.    }
  1027. }
  1028. function cekKuat()
  1029. {
  1030.    if(_root["char" + sChar]._currentframe == 1)
  1031.    {
  1032.       if(_root["char" + sChar].anim_char._currentframe == 1)
  1033.       {
  1034.          if(sedangAngkat == false)
  1035.          {
  1036.             _root["char" + sChar].anim_char.gotoAndStop(6);
  1037.          }
  1038.       }
  1039.       if(mapping[posisiXChar[sChar] - 1][posisiYChar[sChar] + 1] == 7)
  1040.       {
  1041.          j = posisiXChar[sChar] - 1;
  1042.          i = posisiYChar[sChar] + 1;
  1043.          ubahDalam("i","j","dalam");
  1044.          namaBaru = "kotak" + dalam;
  1045.          if(_root[namaBaru]._currentframe == 7)
  1046.          {
  1047.             cekDalam(1);
  1048.             mapping[j][i] = 0;
  1049.          }
  1050.       }
  1051.       else if(mapping[posisiXChar[sChar]][posisiYChar[sChar] + 1] == 7 && mapping[posisiXChar[sChar] - 1][posisiYChar[sChar] + 1] == 0)
  1052.       {
  1053.          j = posisiXChar[sChar];
  1054.          i = posisiYChar[sChar] + 1;
  1055.          ubahDalam("i","j","dalam");
  1056.          namaBaru = "kotak" + dalam;
  1057.          if(_root[namaBaru]._currentframe == 7)
  1058.          {
  1059.             cekDalam(1);
  1060.             mapping[j][i] = 0;
  1061.          }
  1062.       }
  1063.       else if(sedangAngkat == false)
  1064.       {
  1065.          if(mapping[posisiXChar[sChar] - 1][posisiYChar[sChar] + 1] == 9)
  1066.          {
  1067.             _root["char" + sChar].anim_char.gotoAndStop(7);
  1068.             j = posisiXChar[sChar] - 1;
  1069.             i = posisiYChar[sChar] + 1;
  1070.             cekDalam(1);
  1071.             mapping[j][i] = 0;
  1072.             sedangAngkat = true;
  1073.          }
  1074.          else if(mapping[posisiXChar[sChar]][posisiYChar[sChar] + 1] == 9)
  1075.          {
  1076.             _root["char" + sChar].anim_char.gotoAndStop(7);
  1077.             j = posisiXChar[sChar];
  1078.             i = posisiYChar[sChar] + 1;
  1079.             cekDalam(1);
  1080.             mapping[j][i] = 0;
  1081.             sedangAngkat = true;
  1082.          }
  1083.       }
  1084.       else if(sedangAngkat == true)
  1085.       {
  1086.          j = posisiXChar[sChar] + 1;
  1087.          i = posisiYChar[sChar] + 1;
  1088.          ubahDalam("i","j","dalam");
  1089.          namaBaru = "kotak" + dalam;
  1090.          if(mapping[posisiXChar[sChar]][posisiYChar[sChar] + 1] == 0 && mapping[posisiXChar[sChar] + 1][posisiYChar[sChar] + 1] != 0 || _root[namaBaru]._currentframe == 18)
  1091.          {
  1092.             cekTeman("kanan");
  1093.             if(xbisa)
  1094.             {
  1095.                j = posisiXChar[sChar];
  1096.                i = posisiYChar[sChar] + 1;
  1097.                cekDalam(9);
  1098.                mapping[j][i] = 9;
  1099.                sedangAngkat = false;
  1100.                _root["char" + sChar].anim_char.gotoAndStop(8);
  1101.             }
  1102.             else if(_root[namaBaru]._currentframe == 18)
  1103.             {
  1104.                j = posisiXChar[sChar] + 1;
  1105.                i = posisiYChar[sChar] + 1;
  1106.                cekDalam(9);
  1107.                mapping[j][i] = 9;
  1108.                sedangAngkat = false;
  1109.                _root["char" + sChar].anim_char.gotoAndStop(8);
  1110.             }
  1111.          }
  1112.          else if(mapping[posisiXChar[sChar] - 1][posisiYChar[sChar] + 1] == 0)
  1113.          {
  1114.             cekTeman("kanan");
  1115.             if(xbisa)
  1116.             {
  1117.                j = posisiXChar[sChar] - 1;
  1118.                i = posisiYChar[sChar] + 1;
  1119.                cekDalam(9);
  1120.                mapping[j][i] = 9;
  1121.                sedangAngkat = false;
  1122.                xbisa = false;
  1123.                _root["char" + sChar].anim_char.gotoAndStop(8);
  1124.             }
  1125.          }
  1126.       }
  1127.    }
  1128.    else if(_root["char" + sChar]._currentframe == 2)
  1129.    {
  1130.       if(_root["char" + sChar].anim_char._currentframe == 1)
  1131.       {
  1132.          if(sedangAngkat == false)
  1133.          {
  1134.             _root["char" + sChar].anim_char.gotoAndStop(6);
  1135.          }
  1136.       }
  1137.       if(mapping[posisiXChar[sChar] - 1][posisiYChar[sChar] - 1] == 7)
  1138.       {
  1139.          j = posisiXChar[sChar] - 1;
  1140.          i = posisiYChar[sChar] - 1;
  1141.          ubahDalam("i","j","dalam");
  1142.          namaBaru = "kotak" + dalam;
  1143.          if(_root[namaBaru]._currentframe == 7)
  1144.          {
  1145.             cekDalam(1);
  1146.             mapping[j][i] = 0;
  1147.          }
  1148.       }
  1149.       else if(mapping[posisiXChar[sChar]][posisiYChar[sChar] - 1] == 7 && mapping[posisiXChar[sChar] - 1][posisiYChar[sChar] - 1] == 0)
  1150.       {
  1151.          j = posisiXChar[sChar];
  1152.          i = posisiYChar[sChar] - 1;
  1153.          ubahDalam("i","j","dalam");
  1154.          namaBaru = "kotak" + dalam;
  1155.          if(_root[namaBaru]._currentframe == 7)
  1156.          {
  1157.             cekDalam(1);
  1158.             mapping[j][i] = 0;
  1159.          }
  1160.       }
  1161.       else if(sedangAngkat == false)
  1162.       {
  1163.          if(mapping[posisiXChar[sChar] - 1][posisiYChar[sChar] - 1] == 9)
  1164.          {
  1165.             _root["char" + sChar].anim_char.gotoAndStop(7);
  1166.             j = posisiXChar[sChar] - 1;
  1167.             i = posisiYChar[sChar] - 1;
  1168.             cekDalam(1);
  1169.             mapping[j][i] = 0;
  1170.             sedangAngkat = true;
  1171.          }
  1172.          else if(mapping[posisiXChar[sChar]][posisiYChar[sChar] - 1] == 9)
  1173.          {
  1174.             _root["char" + sChar].anim_char.gotoAndStop(7);
  1175.             j = posisiXChar[sChar];
  1176.             i = posisiYChar[sChar] - 1;
  1177.             cekDalam(1);
  1178.             mapping[j][i] = 0;
  1179.             sedangAngkat = true;
  1180.          }
  1181.       }
  1182.       else if(sedangAngkat == true)
  1183.       {
  1184.          if(mapping[posisiXChar[sChar]][posisiYChar[sChar] - 1] == 0 && mapping[posisiXChar[sChar] + 1][posisiYChar[sChar] - 1] != 0)
  1185.          {
  1186.             cekTeman("kiri");
  1187.             if(xbisa)
  1188.             {
  1189.                j = posisiXChar[sChar];
  1190.                i = posisiYChar[sChar] - 1;
  1191.                cekDalam(9);
  1192.                mapping[j][i] = 9;
  1193.                sedangAngkat = false;
  1194.                _root["char" + sChar].anim_char.gotoAndStop(8);
  1195.             }
  1196.          }
  1197.          else if(mapping[posisiXChar[sChar] - 1][posisiYChar[sChar] - 1] == 0)
  1198.          {
  1199.             cekTeman("kiri");
  1200.             if(xbisa)
  1201.             {
  1202.                j = posisiXChar[sChar] - 1;
  1203.                i = posisiYChar[sChar] - 1;
  1204.                cekDalam(9);
  1205.                mapping[j][i] = 9;
  1206.                sedangAngkat = false;
  1207.                xbisa = false;
  1208.                _root["char" + sChar].anim_char.gotoAndStop(8);
  1209.             }
  1210.          }
  1211.       }
  1212.    }
  1213. }
  1214. function cekDalam(indi)
  1215. {
  1216.    ubahDalam("i","j","dalam");
  1217.    namaBaru = "kotak" + dalam;
  1218.    if(_root[namaBaru]._currentframe == 18 || _root[namaBaru]._currentframe == 1 || _root[namaBaru]._currentframe == 5 || _root[namaBaru]._currentframe == 2 || _root[namaBaru]._currentframe == 7 || _root[namaBaru]._currentframe == 8 || _root[namaBaru]._currentframe == 9 || _root[namaBaru]._currentframe == 4)
  1219.    {
  1220.       _root[namaBaru].gotoAndStop(indi);
  1221.    }
  1222. }
  1223. function ubahDalam(i, j, dalam)
  1224. {
  1225.    if(this[i] < 10 && this[j] < 10)
  1226.    {
  1227.       this[dalam] = "0" + String(this[i]) + "0" + String(this[j]);
  1228.    }
  1229.    else if(this[i] < 10 && this[j] >= 10)
  1230.    {
  1231.       this[dalam] = "0" + String(this[i]) + String(this[j]);
  1232.    }
  1233.    else if(this[i] >= 10 && this[j] < 10)
  1234.    {
  1235.       this[dalam] = String(this[i]) + "0" + String(this[j]);
  1236.    }
  1237.    else
  1238.    {
  1239.       this[dalam] = String(this[i]) + String(this[j]);
  1240.    }
  1241. }
  1242. function input()
  1243. {
  1244.    myListener = new Object();
  1245.    myListener.onKeyDown = function()
  1246.    {
  1247.       if(mulaiMain)
  1248.       {
  1249.          if(!xjatuh && !xdiem)
  1250.          {
  1251.             if(Key.getCode() == 38)
  1252.             {
  1253.                xtaliNaik = true;
  1254.             }
  1255.             if(Key.getCode() == 40)
  1256.             {
  1257.                xtaliTurun = true;
  1258.             }
  1259.             if(Key.getCode() == 37)
  1260.             {
  1261.                _root["char" + sChar].gotoAndStop(2);
  1262.                gerakKiri();
  1263.             }
  1264.             if(Key.getCode() == 39)
  1265.             {
  1266.                _root["char" + sChar].gotoAndStop(1);
  1267.                gerakKanan();
  1268.             }
  1269.             if(Key.getCode() == 38)
  1270.             {
  1271.                gerakAtas();
  1272.             }
  1273.             if(Key.getCode() == 40)
  1274.             {
  1275.                gerakBawah();
  1276.             }
  1277.             if(Key.getCode() == 67)
  1278.             {
  1279.                if(sChar == 1)
  1280.                {
  1281.                   if(_root["char" + sChar].anim_char._currentframe == 1)
  1282.                   {
  1283.                      if(mapping[posisiXChar[sChar]][posisiYChar[sChar]] == 4)
  1284.                      {
  1285.                         j = posisiXChar[sChar] + 1;
  1286.                         i = posisiYChar[sChar];
  1287.                         ubahDalam("i","j","dalam3");
  1288.                         namaBaru3 = "kotak" + dalam3;
  1289.                         if(mapping[posisiXChar[sChar] + 1][posisiYChar[sChar]] == 1 || mapping[posisiXChar[sChar] + 1][posisiYChar[sChar]] == 4 && _root[namaBaru3]._currentframe == 5)
  1290.                         {
  1291.                            posisiAmbilX = posisiAmbilX2 = posisiXChar[sChar];
  1292.                            posisiAmbilY = posisiYChar[sChar];
  1293.                            adaOrang = false;
  1294.                            j = posisiAmbilX;
  1295.                            while(j >= 0)
  1296.                            {
  1297.                               i = posisiAmbilY;
  1298.                               ubahDalam("i","j","dalam2");
  1299.                               namaBaru2 = "kotak" + dalam2;
  1300.                               if(_root[namaBaru2]._currentframe == 5)
  1301.                               {
  1302.                                  posisiAmbilX2 = j + 1;
  1303.                                  j = 0;
  1304.                               }
  1305.                               if(posisiYChar[dChar] == i && posisiXChar[dChar] == j - 1 || posisiYChar[dChar] == i && posisiXChar[dChar] == j)
  1306.                               {
  1307.                                  if(_root["char" + dChar].anim_char._currentframe == 1)
  1308.                                  {
  1309.                                     adaOrang = false;
  1310.                                  }
  1311.                                  else
  1312.                                  {
  1313.                                     adaOrang = true;
  1314.                                  }
  1315.                               }
  1316.                               j--;
  1317.                            }
  1318.                            j = posisiAmbilX2 - 1;
  1319.                            i = posisiAmbilY;
  1320.                            if(adaJem[j][i])
  1321.                            {
  1322.                               iniJalan = true;
  1323.                            }
  1324.                            else
  1325.                            {
  1326.                               iniJalan = false;
  1327.                            }
  1328.                            if(adaOrang == false)
  1329.                            {
  1330.                               cekDalam(2);
  1331.                               mapping[j][i] = 1;
  1332.                               xambilTali = true;
  1333.                               xdiem = true;
  1334.                               idAmbil2 = setInterval(ambilTali2,250);
  1335.                               _root["char" + sChar].anim_char.gotoAndStop(6);
  1336.                            }
  1337.                         }
  1338.                      }
  1339.                      else if(mapping[posisiXChar[sChar] + 1][posisiYChar[sChar]] == 4)
  1340.                      {
  1341.                         if(mapping[posisiXChar[sChar]][posisiYChar[sChar]] == 0)
  1342.                         {
  1343.                            posisiAmbilX = posisiAmbilX2 = posisiXChar[sChar] + 1;
  1344.                            posisiAmbilY = posisiYChar[sChar];
  1345.                            adaOrang = false;
  1346.                            j = posisiAmbilX + 1;
  1347.                            while(j <= lebar)
  1348.                            {
  1349.                               i = posisiAmbilY;
  1350.                               ubahDalam("i","j","dalam2");
  1351.                               namaBaru2 = "kotak" + dalam2;
  1352.                               if(mapping[j][i] == 1 || _root[namaBaru2]._currentframe == 5)
  1353.                               {
  1354.                                  posisiAmbilX2 = j - 1;
  1355.                                  j = lebar;
  1356.                               }
  1357.                               if(posisiYChar[dChar] == i && posisiXChar[dChar] == j - 1 || posisiYChar[dChar] == i && posisiXChar[dChar] == j)
  1358.                               {
  1359.                                  if(_root["char" + dChar].anim_char._currentframe == 1)
  1360.                                  {
  1361.                                     adaOrang = false;
  1362.                                  }
  1363.                                  else
  1364.                                  {
  1365.                                     adaOrang = true;
  1366.                                  }
  1367.                               }
  1368.                               j++;
  1369.                            }
  1370.                            if(adaOrang == false)
  1371.                            {
  1372.                               xambilTali = true;
  1373.                               xdiem = true;
  1374.                               idAmbil = setInterval(ambilTali,250);
  1375.                               _root["char" + sChar].anim_char.gotoAndStop(6);
  1376.                            }
  1377.                         }
  1378.                      }
  1379.                   }
  1380.                }
  1381.             }
  1382.             if(Key.getCode() == 88)
  1383.             {
  1384.                if(char1._visible == true)
  1385.                {
  1386.                   if(abilChar == "tali")
  1387.                   {
  1388.                      abilChar = "jalan";
  1389.                      menu_mc.tali_mc.gotoAndStop(2);
  1390.                      menu_mc.jalan_mc.gotoAndStop(1);
  1391.                   }
  1392.                   else if(abilChar == "jalan")
  1393.                   {
  1394.                      abilChar = "tali";
  1395.                      menu_mc.tali_mc.gotoAndStop(1);
  1396.                      menu_mc.jalan_mc.gotoAndStop(2);
  1397.                   }
  1398.                }
  1399.             }
  1400.             if(Key.getCode() == 32)
  1401.             {
  1402.                if(sChar == 0)
  1403.                {
  1404.                   cekKuat();
  1405.                }
  1406.                else if(sChar == 1)
  1407.                {
  1408.                   if(abilChar == "tali")
  1409.                   {
  1410.                      if(xtaliNaik == true)
  1411.                      {
  1412.                         if(tali > 0)
  1413.                         {
  1414.                            if(mapping[posisiXChar[sChar]][posisiYChar[sChar]] == 0)
  1415.                            {
  1416.                               sedangBuatTali = true;
  1417.                               xdiem = true;
  1418.                               _root["char" + sChar].anim_char.gotoAndStop(3);
  1419.                               buatTali();
  1420.                            }
  1421.                         }
  1422.                      }
  1423.                      else if(xtaliTurun == true)
  1424.                      {
  1425.                         if(tali > 0)
  1426.                         {
  1427.                            if(mapping[posisiXChar[sChar] + 2][posisiYChar[sChar]] == 0)
  1428.                            {
  1429.                               sedangBuatTali = true;
  1430.                               xdiem = true;
  1431.                               _root["char" + sChar].anim_char.gotoAndStop(6);
  1432.                               buatTali2();
  1433.                            }
  1434.                         }
  1435.                      }
  1436.                   }
  1437.                   else if(abilChar == "jalan")
  1438.                   {
  1439.                      buatJalan();
  1440.                   }
  1441.                }
  1442.             }
  1443.             if(Key.getCode() == 90)
  1444.             {
  1445.                if(jumlahKeluar == 0)
  1446.                {
  1447.                   if(!xjatuh)
  1448.                   {
  1449.                      if(sChar == 0)
  1450.                      {
  1451.                         sChar = 1;
  1452.                         dChar = 0;
  1453.                         menu_mc.mark_mc.gotoAndStop(1);
  1454.                         menu_mc.jason_mc.gotoAndStop(2);
  1455.                         menu_mc.nama_mc.gotoAndStop(1);
  1456.                      }
  1457.                      else
  1458.                      {
  1459.                         sChar = 0;
  1460.                         dChar = 1;
  1461.                         menu_mc.mark_mc.gotoAndStop(2);
  1462.                         menu_mc.jason_mc.gotoAndStop(1);
  1463.                         menu_mc.nama_mc.gotoAndStop(2);
  1464.                      }
  1465.                   }
  1466.                }
  1467.             }
  1468.          }
  1469.       }
  1470.    };
  1471.    myListener.onKeyUp = function()
  1472.    {
  1473.       if(mulaiMain)
  1474.       {
  1475.          if(Key.getCode() == 38)
  1476.          {
  1477.             xtaliNaik = false;
  1478.          }
  1479.          if(Key.getCode() == 40)
  1480.          {
  1481.             xtaliTurun = false;
  1482.          }
  1483.       }
  1484.    };
  1485.    Key.addListener(myListener);
  1486. }
  1487. stop();
  1488. mulaiMain = true;
  1489. this.attachMovie("back_mc","back_mc",this.getNextHighestDepth());
  1490. back_mc.kotak1._visible = false;
  1491. back_mc.kotak2._visible = false;
  1492. initAwal();
  1493. init();
  1494. buatKotak();
  1495. buatChar();
  1496. if(satuKaliSaja)
  1497. {
  1498.    satuKaliSaja = false;
  1499.    input();
  1500. }
  1501. this.attachMovie("menu_mc","menu_mc",this.getNextHighestDepth(),{_x:10,_y:480});
  1502. initMenu();
  1503. idJatuh = setInterval(jatuh,250);
  1504. idWaktu = setInterval(waktuMaju,1000);
  1505. this.onEnterFrame = function()
  1506. {
  1507.    menu_mc.tanah = tanah;
  1508.    menu_mc.tali = tali;
  1509.    menit = int(waktu / 60);
  1510.    detik = int(waktu) - menit * 60;
  1511.    if(menit < 10)
  1512.    {
  1513.       menit = "0" + menit;
  1514.    }
  1515.    if(detik < 10)
  1516.    {
  1517.       detik = "0" + detik;
  1518.    }
  1519.    if(int(menit) >= 1)
  1520.    {
  1521.       menu_mc.waktu = menit + "." + detik;
  1522.    }
  1523.    else
  1524.    {
  1525.       menu_mc.waktu = "00." + detik;
  1526.    }
  1527.    if(jalanKanan)
  1528.    {
  1529.       if(_root["char" + sChar].anim_char.jalan1._currentframe == 9 || _root["char" + sChar].anim_char.jalan2._currentframe == 9)
  1530.       {
  1531.          if(sudahJatuh == true)
  1532.          {
  1533.             sedangNahan = false;
  1534.             batuJatuh = true;
  1535.          }
  1536.          _root["char" + sChar].anim_char.gotoAndStop(1);
  1537.          posisiYChar[sChar]++;
  1538.          xdiem = false;
  1539.          jalanKanan = false;
  1540.          _root["char" + sChar]._x = posisiYChar[sChar] * 40;
  1541.          cekChar("kanan");
  1542.          cekWin();
  1543.       }
  1544.    }
  1545.    if(jalanKiri)
  1546.    {
  1547.       if(_root["char" + sChar].anim_char.jalan1._currentframe == 9 || _root["char" + sChar].anim_char.jalan2._currentframe == 9)
  1548.       {
  1549.          if(sudahJatuh == true)
  1550.          {
  1551.             sedangNahan = false;
  1552.             batuJatuh = true;
  1553.          }
  1554.          _root["char" + sChar].anim_char.gotoAndStop(1);
  1555.          _root["char" + sChar].anim_char.gotoAndStop(1);
  1556.          posisiYChar[sChar]--;
  1557.          xdiem = false;
  1558.          jalanKiri = false;
  1559.          _root["char" + sChar]._x = posisiYChar[sChar] * 40;
  1560.          cekChar("kiri");
  1561.          cekWin();
  1562.       }
  1563.    }
  1564.    if(jalanAtas)
  1565.    {
  1566.       if(sudahAtas[sChar] == false && _root["char" + sChar].anim_char.naik._currentframe == 8 || sudahAtas[sChar] == true && _root["char" + sChar].anim_char.naik._currentframe == 16)
  1567.       {
  1568.          if(sudahAtas[sChar])
  1569.          {
  1570.             gerakBawahAwal[sChar] = true;
  1571.             posisiXChar[sChar]--;
  1572.             _root["char" + sChar].anim_char.gotoAndStop(1);
  1573.          }
  1574.          xdiem = false;
  1575.          jalanAtas = false;
  1576.          posisiXChar[sChar]--;
  1577.          _root["char" + sChar]._y = posisiXChar[sChar] * 40;
  1578.          cekChar("atas");
  1579.          cekWin();
  1580.       }
  1581.    }
  1582.    if(jalanBawah)
  1583.    {
  1584.       if(sudahBawah[sChar] == true && _root["char" + sChar].anim_char.bawah._currentframe == 8 || sudahBawah[sChar] == false && _root["char" + sChar].anim_char.bawah._currentframe == 16)
  1585.       {
  1586.          sudahAtas[sChar] = false;
  1587.          if(awalTurun[sChar] == true)
  1588.          {
  1589.             sudahAtas[sChar] = true;
  1590.             posisiXChar[sChar]++;
  1591.          }
  1592.          posisiXChar[sChar]++;
  1593.          _root["char" + sChar]._y = posisiXChar[sChar] * 40;
  1594.          xdiem = false;
  1595.          jalanBawah = false;
  1596.          cekChar("bawah");
  1597.          cekWin();
  1598.       }
  1599.       else if(sudahBawah[sChar] == false && _root["char" + sChar].anim_char.bawah._currentframe == 8)
  1600.       {
  1601.          xdiem = false;
  1602.       }
  1603.    }
  1604.    if(jumlahKeluar == 0)
  1605.    {
  1606.       if(!xdiem)
  1607.       {
  1608.          menu_mc.jason_mc.enabled = true;
  1609.          menu_mc.mark_mc.enabled = true;
  1610.          char0.enabled = true;
  1611.          char1.enabled = true;
  1612.       }
  1613.       else
  1614.       {
  1615.          menu_mc.jason_mc.enabled = false;
  1616.          menu_mc.mark_mc.enabled = false;
  1617.          char0.enabled = false;
  1618.          char1.enabled = false;
  1619.       }
  1620.    }
  1621. };
  1622.